/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package inventorymanagement;

/**
 *
 * @author Administrator
 */


import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Vector;

import javax.swing.JComboBox;
import javax.swing.JFrame;


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;


public class Items extends JFrame implements ActionListener{

    JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,label10;
    JButton SUBMIT;
   public static int  I1MotorolaW377=10;
   public static int  I1iPhone1G=10;
   public static int  I1Nokia6300=10;
     public static int  I2NokiaX3=10;
   public static int  I2MotorolaMg=10;
   
 
    
     JFrame frame = new JFrame("Items List");
     JComboBox combo1; 
     JTextField txt;
     JTextField  text1;
    public void Items1(){
        
        
        String myitems[]={"MotorolaW377","iPhone1G","Nokia6300"};
            
       
       text1= new JTextField(15);
        
         
         
        System.out.println("Item1");
        label1 = new JLabel();
        label1.setText("The Availabale Items In product no 0 Are  ");
        
        label2 = new JLabel();
        label2.setText("1.MotorolaW377-"+I1MotorolaW377);   
        
        label3 = new JLabel();
        label3.setText("2.iPhone1G-"+I1iPhone1G);     
        
        label4 = new JLabel();
        label4.setText("3.Nokia6300-"+I1Nokia6300);  
        
        txt = new JTextField(10);
        label5 = new JLabel();
        label5.setText("Please Select At Least One Item"); 
        
          combo1 = new JComboBox(myitems);

                
        
        label6 = new JLabel();
        label6.setText("Enter the Quantity You Want ?"); 
        
      
        
         SUBMIT=new JButton("SUBMIT");
        
     
        
                
        
        JPanel panel = new JPanel(new GridLayout(9,1));
        
         panel.add(label1);
         panel.add(label2);
         panel.add(label3);
         panel.add(label4);
         panel.add(label5);
         panel.add(combo1);
         panel.add(label6);
         panel.add(text1);
         panel.add(SUBMIT);
         add(panel,BorderLayout.CENTER);
         frame.add(panel);
         
         SUBMIT.addActionListener(this);
          
         
        
       
         
         
        combo1.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie){
String str = (String)combo1.getSelectedItem();
//System.out.print("hii");
txt.setText(str);

}
});
      
   frame.setSize(500,500);
   frame.setVisible(true);  
   
    }     
     
       public void Items2(){
                   
        String myitems[]={"NokiaX3","MotorolaMg"};
            
       
         text1= new JTextField(15);
        
         
         
        System.out.println("Item1");
        label1 = new JLabel();
        label1.setText("The Availabale Items In product no 0 Are  ");
        
        label2 = new JLabel();
        label2.setText("1.MotorolaW377-"+ I2NokiaX3);   
        
        label3 = new JLabel();
        label3.setText("2.iPhone1G-"+I2MotorolaMg);     
        
      
        
        txt = new JTextField(10);
        label5 = new JLabel();
        label5.setText("Please Select At Least One Item"); 
        
          combo1 = new JComboBox(myitems);

                
        
        label6 = new JLabel();
        label6.setText("Enter the Quantity You Want ?"); 
        
      
        
         SUBMIT=new JButton("SUBMIT");
        
     
        
                
        
        JPanel panel = new JPanel(new GridLayout(8,1));
        
         panel.add(label1);
         panel.add(label2);
         panel.add(label3);
      
         panel.add(label5);
         panel.add(combo1);
         panel.add(label6);
         panel.add(text1);
         panel.add(SUBMIT);
         add(panel,BorderLayout.CENTER);
         frame.add(panel);
         
         SUBMIT.addActionListener(this);
          
         
        
       
         
         
        combo1.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie){
String str = (String)combo1.getSelectedItem();
//System.out.print("hii");
txt.setText(str);

}
});
      
   frame.setSize(500,500);
   frame.setVisible(true);  
       }
       
       public void Items3(){
           
       }
         
       public void Items4(){
           
       }
           
       public void Items5(){
           
       }
     public void actionPerformed(ActionEvent ae)
     {
           String value1=txt.getText(); 
           String value2=text1.getText();
           int val3=Integer.parseInt(value2);
           
           frame.dispose();
           if(value1.equals("MotorolaW377")){
              
              Items.I1MotorolaW377=Items.I1MotorolaW377-val3;
              
              AvailableItems av=new AvailableItems();
              av.available();
             
           }
           else if(value1.equals("iPhone1G")){
                Items.I1iPhone1G=Items.I1iPhone1G-val3;
                AvailableItems av=new AvailableItems();
                av.available();
            
           }
           else if(value1.equals("Nokia6300")){
                Items.I1Nokia6300=Items.I1Nokia6300-val3;
                AvailableItems av=new AvailableItems();
                av.available();
           }
           
           else if(value1.equals("NokiaX3")){
                Items.I2NokiaX3=Items.I2NokiaX3-val3;
                AvailableItems av=new AvailableItems();
                av.available1();
           }
           
              else if(value1.equals("MotorolaMg")){
                Items.I2MotorolaMg=Items.I2MotorolaMg-val3;
                AvailableItems av=new AvailableItems();
                av.available1();
           }
           
          
     }
}
